package com.cdh.edu.controller.api;

import com.cdh.edu.entity.Course;
import com.cdh.edu.entity.Teacher;
import com.cdh.edu.service.CourseService;
import com.cdh.edu.service.TeacherService;
import com.cdh.utils.result.Restful;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author by cdh
 * @description:
 * @Date: Created in 13:22 on 2021/3/2
 */
@Api(tags = "首页")
@RestController
@RequestMapping("api/edu/index")
@CrossOrigin
public class ApiIndexController {

    @Autowired
    private CourseService courseService;
    @Autowired
    private TeacherService teacherService;

    @ApiOperation("课程和讲师的首页数据")
    @GetMapping
    public Restful index(){
        // 查询热门课程
        List<Course> courseList = courseService.selectHotCourse();

        // 查询推荐讲师
        List<Teacher> teacherList = teacherService.selectHotTeacher();

        return Restful.ok().data("courseList",courseList).data("teacherList",teacherList);
    }
}
